package com.voxel.sense.infomsg.data.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

/**
 * Created by chenyiyao on 2017/11/2.
 */

public class ConditionBean implements Parcelable {
    private String type; //类型
    private String tipCode;//id
    private String desc; //描述文本
    private String url;//图标的url
    private boolean isSelect; //记录选中状态

    public ConditionBean(String type, String tipCode, String desc, boolean isSelect) {
        this.type = type;
        this.tipCode = tipCode;
        this.desc = desc;
        this.isSelect = isSelect;
    }

    public ConditionBean(String type, String tipCode, String desc, String url, boolean isSelect) {
        this.type = type;
        this.tipCode = tipCode;
        this.desc = desc;
        this.url = url;
        this.isSelect = isSelect;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTipCode() {
        return tipCode;
    }

    public void setTipCode(String tipCode) {
        this.tipCode = tipCode;
    }

    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.type);
        dest.writeString(this.tipCode);
        dest.writeString(this.desc);
        dest.writeString(this.url);
        dest.writeByte(this.isSelect ? (byte) 1 : (byte) 0);
    }

    protected ConditionBean(Parcel in) {
        this.type = in.readString();
        this.tipCode = in.readString();
        this.desc = in.readString();
        this.url = in.readString();
        this.isSelect = in.readByte() != 0;
    }

    public static final Creator<ConditionBean> CREATOR = new Creator<ConditionBean>() {
        @Override
        public ConditionBean createFromParcel(Parcel source) {
            return new ConditionBean(source);
        }

        @Override
        public ConditionBean[] newArray(int size) {
            return new ConditionBean[size];
        }
    };



    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ConditionBean) {
            ConditionBean bean = (ConditionBean) obj;
            if (TextUtils.isEmpty(type) || TextUtils.isEmpty(tipCode)) return false;
            else if (type.equals(bean.type) && tipCode.equals(bean.tipCode)) return true;
        }
        return super.equals(obj);
    }
}
